import Conditions from '../../../../../resources/conditions';
import { Responses } from '../../../../../resources/responses';
import ZoneId from '../../../../../resources/zone_id';
import { RaidbossData } from '../../../../../types/data';
import { TriggerSet } from '../../../../../types/trigger';

export interface Data extends RaidbossData {
  magicVulnerability?: boolean;
  haveWater?: boolean;
  haveLightning?: boolean;
}

const triggerSet: TriggerSet<Data> = {
  id: 'AlexanderTheCuffOfTheSonSavage',
  zoneId: ZoneId.AlexanderTheCuffOfTheSonSavage,
  timelineFile: 'a6s.txt',
  triggers: [
    {
      id: 'A6S Magic Vulnerability Gain',
      type: 'GainsEffect',
      netRegex: { effectId: '292' },
      condition: Conditions.targetIsYou(),
      run: (data) => data.magicVulnerability = true,
    },
    {
      id: 'A6S Magic Vulnerability Loss',
      type: 'LosesEffect',
      netRegex: { effectId: '292' },
      condition: Conditions.targetIsYou(),
      run: (data) => data.magicVulnerability = false,
    },
    {
      id: 'A6S Mind Blast',
      type: 'StartsUsing',
      netRegex: { source: 'Blaster', id: '15F3' },
      condition: (data) => data.CanSilence(),
      response: Responses.interrupt(),
    },
    {
      id: 'A6S Hidden Minefield',
      type: 'StartsUsing',
      netRegex: { source: 'Blaster', id: '15F7', capture: false },
      infoText: (data, _matches, output) => {
        if (data.role === 'tank' && !data.magicVulnerability)
          return output.getMines!();

        return output.avoidMines!();
      },
      outputStrings: {
        getMines: {
          en: 'Get Mines',
          de: 'Mienen nehmen',
          fr: 'Prenez les mines',
          ja: '地雷を踏む',
          cn: '踩雷',
          ko: '지뢰 밟기',
        },
        avoidMines: {
          en: 'Avoid Mines',
          de: 'Mienen vermeiden',
          fr: 'Évitez les mines',
          ja: '地雷を踏まない',
          cn: '躲开地雷',
          ko: '지뢰 피하기',
        },
      },
    },
    {
      id: 'A6S Supercharge',
      type: 'StartsUsing',
      netRegex: { source: 'Blaster Mirage', id: '15FB', capture: false },
      suppressSeconds: 1,
      infoText: (_data, _matches, output) => output.text!(),
      outputStrings: {
        text: {
          en: 'Dodge Mirage Charge',
          de: 'Superladung ausweichen',
          fr: 'Esquivez la charge de la réplique',
          ja: 'スーパーチャージを避ける',
          cn: '躲开冲锋',
          ko: '환영 돌진 피하기',
        },
      },
    },
    {
      id: 'A6S Blinder',
      type: 'StartsUsing',
      netRegex: { source: 'Blaster Mirage', id: '15FC' },
      condition: Conditions.targetIsYou(),
      alertText: (_data, _matches, output) => output.text!(),
      outputStrings: {
        text: {
          en: 'Look Away from Mirage',
          de: 'Von Replikant wegschauen',
          fr: 'Ne regardez pas la réplique',
          ja: 'ミラージュを見ない',
          cn: '背对幻象',
          ko: '환영 쳐다보지 않기',
        },
      },
    },
    {
      id: 'A6S Power Tackle',
      type: 'StartsUsing',
      netRegex: { source: 'Blaster Mirage', id: '15FD' },
      condition: Conditions.targetIsYou(),
      alertText: (_data, _matches, output) => output.text!(),
      outputStrings: {
        text: {
          en: 'Look Towards Mirage',
          de: 'Von Replikant hinschauen',
          fr: 'Regardez la réplique',
          ja: 'ミラージュを見る',
          cn: '面向幻象',
          ko: '환영 쳐다보기',
        },
      },
    },
    {
      id: 'A6S Low Arithmeticks',
      type: 'GainsEffect',
      netRegex: { effectId: '3FD' },
      condition: Conditions.targetIsYou(),
      suppressSeconds: 10,
      alertText: (_data, _matches, output) => output.text!(),
      outputStrings: {
        text: {
          en: 'Go High',
          de: 'Geh Hoch',
          fr: 'Allez en haut',
          ja: '高い床に乗る',
          cn: '上高台',
          ko: '높은곳으로',
        },
      },
    },
    {
      id: 'A6S High Arithmeticks',
      type: 'GainsEffect',
      netRegex: { effectId: '3FE' },
      condition: Conditions.targetIsYou(),
      suppressSeconds: 10,
      alertText: (_data, _matches, output) => output.text!(),
      outputStrings: {
        text: {
          en: 'Go Low',
          de: 'Geh Runter',
          fr: 'Allez en bas',
          ja: '低い床に乗る',
          cn: '下低台',
          ko: '낮은곳으로',
        },
      },
    },
    {
      id: 'A6S Bio-arithmeticks',
      type: 'StartsUsing',
      netRegex: { source: 'Swindler', id: '1610', capture: false },
      response: Responses.aoe(),
    },
    {
      id: 'A6S Midan Hardhelm',
      type: 'StartsUsing',
      netRegex: { source: 'Midan Hardhelm', id: '1612' },
      condition: (data) => data.CanStun(),
      response: Responses.stun(),
    },
    {
      id: 'A6S Midan Hardmind',
      type: 'StartsUsing',
      netRegex: { source: 'Midan Hardhelm', id: '1613' },
      condition: (data) => data.CanStun(),
      response: Responses.stun(),
    },
    {
      id: 'A6S Enumeration',
      type: 'HeadMarker',
      netRegex: { id: ['0040', '0041', '0042'] },
      infoText: (data, matches, output) => {
        // 0040 = 2, 0041 = 3, 0042 = 4
        const count = 2 + parseInt(matches.id, 16) - parseInt('0040', 16);
        return output.text!({ player: data.party.member(matches.target), count: count });
      },
      outputStrings: {
        text: {
          en: '${player}: ${count}',
          de: '${player}: ${count}',
          fr: '${player}: ${count}',
          ja: '${player}: ${count}',
          cn: '${player}生命计算法: ${count}',
          ko: '${player}: ${count}',
        },
      },
    },
    {
      id: 'A6S Super Cyclone',
      type: 'StartsUsing',
      netRegex: { source: 'Vortexer', id: '1627', capture: false },
      response: Responses.knockback(),
    },
    {
      id: 'A6S Ultra Flash',
      type: 'StartsUsing',
      netRegex: { source: 'Vortexer', id: '161A', capture: false },
      alertText: (_data, _matches, output) => output.text!(),
      outputStrings: {
        text: {
          en: 'Hide Behind Ice',
          de: 'Hinter dem Eis verstecken',
          fr: 'Cachez-vous derrière la glace',
          ja: '氷柱の後ろに',
          cn: '躲在冰柱之后',
          ko: '얼음 뒤에 숨기',
        },
      },
    },
    {
      id: 'A6S Ice Marker',
      type: 'HeadMarker',
      netRegex: { id: '0043' },
      condition: Conditions.targetIsYou(),
      alarmText: (_data, _matches, output) => output.text!(),
      outputStrings: {
        text: {
          en: 'Ice: Freeze Tornado',
          de: 'Eis: Tornado einfrieren',
          fr: 'Glace : Gelez la tornade',
          ja: '氷柱: 竜巻を凍結',
          cn: '冰柱: 冻结龙卷风',
          ko: '얼음: 물기둥 얼리기',
        },
      },
    },
    {
      id: 'A6S Fire Beam',
      type: 'HeadMarker',
      netRegex: { id: '0019' },
      condition: Conditions.targetIsYou(),
      // TODO: maybe this should say "hit tornado / avoid ice" but that's wordy.
      infoText: (_data, _matches, output) => output.text!(),
      outputStrings: {
        text: {
          en: 'Fire Beam on YOU',
          de: 'Feuer Strahl auf DIR',
          fr: 'Rayon de feu sur VOUS',
          ja: '自分にファイアビーム',
          cn: '火焰光束点名',
          ko: '화염 광선 대상자',
        },
      },
    },
    {
      id: 'A6S Compressed Water Initial',
      type: 'GainsEffect',
      netRegex: { effectId: '3FF' },
      condition: Conditions.targetIsYou(),
      infoText: (_data, _matches, output) => output.text!(),
      run: (data) => data.haveWater = true,
      outputStrings: {
        text: {
          en: 'Water on YOU',
          de: 'Wasser auf DIR',
          fr: 'Eau sur VOUS',
          ja: '自分に水',
          cn: '水点名',
          ko: '물징 대상자',
        },
      },
    },
    {
      id: 'A6S Compressed Water Lose',
      type: 'LosesEffect',
      netRegex: { effectId: '3FF' },
      condition: Conditions.targetIsYou(),
      run: (data) => data.haveWater = false,
    },
    {
      id: 'A6S Compressed Water Explode',
      type: 'GainsEffect',
      netRegex: { effectId: '3FF' },
      condition: Conditions.targetIsYou(),
      delaySeconds: (_data, matches) => parseFloat(matches.duration) - 5,
      alertText: (data, _matches, output) => {
        if (!data.haveWater)
          return;
        return output.text!();
      },
      outputStrings: {
        text: {
          en: 'Drop Water Soon',
          de: 'Gleich Wasser ablegen',
          fr: 'Déposez l\'eau bientôt',
          ja: '水来るよ',
          cn: '马上水分摊',
          ko: '곧 물징 폭발',
        },
      },
    },
    {
      id: 'A6S Compressed Lightning Initial',
      type: 'GainsEffect',
      netRegex: { effectId: '400' },
      condition: Conditions.targetIsYou(),
      infoText: (_data, _matches, output) => output.text!(),
      run: (data) => data.haveLightning = true,
      outputStrings: {
        text: {
          en: 'Lightning on YOU',
          de: 'Blitz auf DIR',
          fr: 'Éclair sur VOUS',
          ja: '自分に雷',
          cn: '雷点名',
          ko: '번개징 대상자',
        },
      },
    },
    {
      id: 'A6S Compressed Lightning Lose',
      type: 'LosesEffect',
      netRegex: { effectId: '400' },
      condition: Conditions.targetIsYou(),
      run: (data) => data.haveLightning = false,
    },
    {
      id: 'A6S Compressed Lightning Explode',
      type: 'GainsEffect',
      netRegex: { effectId: '400' },
      condition: Conditions.targetIsYou(),
      delaySeconds: (_data, matches) => parseFloat(matches.duration) - 5,
      alertText: (data, _matches, output) => {
        if (!data.haveLightning)
          return;
        return output.text!();
      },
      outputStrings: {
        text: {
          en: 'Drop Lightning Soon',
          de: 'Gleich Blitz ablegen',
          fr: 'Déposez l\'éclair bientôt',
          ja: '雷来るよ',
          cn: '马上雷分摊',
          ko: '곧 번개징 폭발',
        },
      },
    },
  ],
  timelineReplace: [
    {
      'locale': 'de',
      'replaceSync': {
        'Blaster(?! Mirage)': 'Blaster',
        'Blaster Mirage': 'Blaster-Replikant',
        'Brawler': 'Blechbrecher',
        'Machinery Bay 67': 'Kampfmaschinen-Baracke 67',
        'Machinery Bay 68': 'Kampfmaschinen-Baracke 68',
        'Machinery Bay 69': 'Kampfmaschinen-Baracke 69',
        'Machinery Bay 70': 'Kampfmaschinen-Baracke 70',
        'Midan Gunner': 'Midas-Schütze',
        'Midan Hardhelm': 'Midas-Harthelm',
        'Power Plasma Alpha': 'Kraftplasma Alpha',
        'Swindler': 'Schwindler',
        'Vortexer': 'Wirbler',
      },
      'replaceText': {
        '--unseal--': '--öffnen--',
        'Attachment': 'Anlegen',
        'Auxiliary Power': 'Notstrom',
        'Ballistic Missile': 'Ballistische Rakete',
        'Bio-Arithmeticks': 'Biomathematik',
        'Brawler Mechanic': 'Brawler Mechanik',
        'Brute Force': 'Brutaler Schlag',
        'Crashing Thunder': 'Brechende Wolke',
        'Crashing Wave': 'Brechende Welle',
        'Earth Missile': 'Erd-Geschoss',
        'Elemental Jammer': 'Elementarstörer',
        'Enumeration': 'Zählen',
        'Fire Beam': 'Feuerstrahl',
        'Gobwalker': 'Gobwalker',
        'Height': 'Nivellierung',
        'Hidden Minefield': 'Getarntes Minenfeld',
        'Ice Missile': 'Eisgeschoss',
        'Magicked Mark': 'Magiegeschoss',
        'Midan Gunner': 'Midas-Schütze',
        'Midan Hardhelm': 'Midas-Harthelm',
        'Midan Hardmind': 'Midas-Sturschale',
        'Midan Soldier': 'Midas-Soldat',
        'Mind Blast': 'Geiststoß',
        'Mirage': 'Illusion',
        'Power Plasma Alpha': 'Kraftplasma Alpha',
        'Power Plasma Beta': 'Kraftplasma Beta',
        'Power Plasma Gamma': 'Kraftplasma Gamma',
        'Snipethoom': 'Fangschuss',
        'Super Cyclone': 'Superzyklon',
        'Ultra Flash': 'Ultrablitz',
      },
    },
    {
      'locale': 'fr',
      'replaceSync': {
        'Blaster(?! Mirage)': 'Fracasseur',
        'Blaster Mirage': 'réplique du Fracasseur',
        'Brawler': 'Bagarreur',
        'Machinery Bay 67': 'Hangar d\'armement HA-67',
        'Machinery Bay 68': 'Hangar d\'armement HA-68',
        'Machinery Bay 69': 'Hangar d\'armement HA-69',
        'Machinery Bay 70': 'Hangar d\'armement HA-70',
        'Midan Gunner': 'canonnier midin',
        'Power Plasma Alpha': 'plasma puissant α',
        'Swindler': 'Arnaqueur',
        'Vortexer': 'Tourbillonneur',
        'Midan Hardhelm': 'casque-dur midin',
      },
      'replaceText': {
        '--unseal--': '--descellement--',
        'Attachment': 'Extension',
        'Auxiliary Power': 'Soutien énergétique',
        'Ballistic Missile': 'Missiles balistiques',
        'Bio-Arithmeticks': 'Biomathématiques',
        'Brawler Mechanic': 'Mécanique du Bagarreur',
        'Brute Force': 'Force brute',
        'Crashing Thunder': 'Éclair percutant',
        'Crashing Wave': 'Vague percutante',
        'Earth Missile': 'Missile de terre',
        'Elemental Jammer': 'Grippage élémentaire',
        'Enumeration': 'Compte',
        'Fire Beam': 'Rayon de feu',
        'Gobwalker': 'Gobblindé',
        'Height': 'Dénivellation',
        'Hidden Minefield': 'Champ de mines caché',
        'Ice Missile': 'Missile de glace',
        'Magicked Mark': 'Tir magique',
        'Midan Gunner': 'canonnier midin',
        'Midan Hardhelm': 'casque-dur midin',
        'Midan Hardmind': 'cerveau-dur midin',
        'Midan Soldier': 'soldat midin',
        'Mind Blast': 'Explosion mentale',
        'Mirage': 'Mirage',
        'Power Plasma Alpha': 'plasma puissant α',
        'Power Plasma Beta': 'plasma puissant β',
        'Power Plasma Gamma': 'plasma puissant γ',
        'Snipethoom': 'Tir précis',
        'Super Cyclone': 'Super cyclone',
        'Ultra Flash': 'Ultraflash',
      },
    },
    {
      'locale': 'ja',
      'replaceSync': {
        'Blaster(?! Mirage)': 'ブラスター',
        'Blaster Mirage': 'ブラスター・ミラージュ',
        'Brawler': 'ブロウラー',
        'Machinery Bay 67': '第67機工兵格納庫',
        'Machinery Bay 68': '第68機工兵格納庫',
        'Machinery Bay 69': '第69機工兵格納庫',
        'Machinery Bay 70': '第70機工兵格納庫',
        'Midan Gunner': 'ミダース・ガンナー',
        'Power Plasma Alpha': 'パワープラズマα',
        'Swindler': 'スウィンドラー',
        'Vortexer': 'ボルテッカー',
        'Midan Hardhelm': 'ミダース・ハードヘルム',
      },
      'replaceText': {
        '--unseal--': '--エリア開放--',
        'Attachment': 'アタッチメント',
        'Auxiliary Power': 'エネルギー支援',
        'Ballistic Missile': 'ミサイル発射',
        'Bio-Arithmeticks': '生命計算術',
        'Brawler Mechanic': 'ブロウラー ギミック',
        'Brute Force': 'ブルートパンチ',
        'Crashing Thunder': 'クラッシュサンダー',
        'Crashing Wave': 'クラッシュウェーブ',
        'Earth Missile': 'アースミサイル',
        'Elemental Jammer': 'エレメンタルジャミング',
        'Enumeration': 'カウント',
        'Fire Beam': 'ファイアビーム',
        'Gobwalker': 'ゴブリウォーカーL型',
        'Height': 'ハイト',
        'Hidden Minefield': 'ステルス地雷散布',
        'Ice Missile': 'アイスミサイル',
        'Magicked Mark': 'マジックショット',
        'Midan Gunner': 'ミダース・ガンナー',
        'Midan Hardhelm': 'ミダース・ハードヘルム',
        'Midan Hardmind': 'ミダース・ハードマインド',
        'Midan Soldier': 'ミダース・ソルジャー',
        'Mind Blast': 'マインドブラスト',
        'Mirage': 'ミラージュシステム',
        'Power Plasma Alpha': 'パワープラズマα',
        'Power Plasma Beta': 'パワープラズマβ',
        'Power Plasma Gamma': 'パワープラズマγ',
        'Snipethoom': '狙撃',
        'Super Cyclone': 'スーパーサイクロン',
        'Ultra Flash': 'ウルトラフラッシュ',
      },
    },
    {
      'locale': 'cn',
      'replaceSync': {
        'Blaster(?! Mirage)': '爆破者',
        'Blaster Mirage': '爆破者幻象',
        'Brawler': '争斗者',
        'Machinery Bay 67': '第67机工兵仓库',
        'Machinery Bay 68': '第68机工兵仓库',
        'Machinery Bay 69': '第69机工兵仓库',
        'Machinery Bay 70': '第70机工兵仓库',
        'Midan Gunner': '弥达斯炮手',
        'Power Plasma Alpha': '强离子体α',
        'Swindler': '欺诈者',
        'Vortexer': '环旋者',
        'Midan Hardhelm': '弥达斯硬盔兵',
      },
      'replaceText': {
        '--unseal--': '--解除封锁--',
        'Attachment': '配件更换',
        'Auxiliary Power': '能量支援',
        'Ballistic Missile': '导弹发射',
        'Bio-Arithmeticks': '生命计算术',
        'Brawler Mechanic': '争斗者技能',
        'Brute Force': '残暴铁拳',
        'Crashing Thunder': '冲击雷',
        'Crashing Wave': '冲击波',
        'Earth Missile': '大地导弹',
        'Elemental Jammer': '元素干扰',
        'Enumeration': '计数',
        'Fire Beam': '火焰光束',
        'Gobwalker': '哥布林战车',
        'Height': '高度算术',
        'Hidden Minefield': '隐形地雷散布',
        'Ice Missile': '寒冰导弹',
        'Magicked Mark': '魔力射击',
        'Midan Gunner': '弥达斯炮手',
        'Midan Hardhelm': '弥达斯硬盔兵',
        'Midan Hardmind': '弥达斯铁心兵',
        'Midan Soldier': '弥达斯士兵',
        'Mind Blast': '精神冲击',
        'Mirage': '幻影系统',
        'Power Plasma Alpha': '强离子体α',
        'Power Plasma Beta': '强离子体β',
        'Power Plasma Gamma': '强离子体γ',
        'Snipethoom': '狙击',
        'Super Cyclone': '超级气旋',
        'Ultra Flash': '究极闪光',
      },
    },
    {
      'locale': 'ko',
      'replaceSync': {
        'Blaster(?! Mirage)': '폭파자',
        'Blaster Mirage': '폭파자의 환영',
        'Brawler': '폭격자',
        'Machinery Bay 67': '제67기공병 격납고',
        'Machinery Bay 68': '제68기공병 격납고',
        'Machinery Bay 69': '제69기공병 격납고',
        'Machinery Bay 70': '제70기공병 격납고',
        'Midan Gunner': '미다스 총잡이',
        'Power Plasma Alpha': '파워 플라스마 α',
        'Swindler': '조작자',
        'Vortexer': '교반자',
        'Midan Hardhelm': '미다스 강화투구',
      },
      'replaceText': {
        '--unseal--': '--봉인 해제--',
        'Attachment': '무기 장착',
        'Auxiliary Power': '에너지 지원',
        'Ballistic Missile': '미사일 발사',
        'Bio-Arithmeticks': '생명계산술',
        'Brute Force': '폭력적인 주먹',
        'Brawler Mechanic': '한손/양손 버스터/드릴',
        'Crashing Thunder': '충격의 번개',
        'Crashing Wave': '충격의 파도',
        'Earth Missile': '대지 미사일',
        'Elemental Jammer': '원소 간섭',
        'Enumeration': '계산',
        'Fire Beam': '화염 광선',
        'Gobwalker': '고블린워커',
        'Height': '고도',
        'Hidden Minefield': '은폐 지뢰 살포',
        'Ice Missile': '얼음 미사일',
        'Magicked Mark': '마법 사격',
        'Midan Gunner': '미다스 총잡이',
        'Midan Hardhelm': '미다스 강화투구',
        'Midan Hardmind': '미다스 강화두뇌',
        'Midan Soldier': '미다스 병사',
        'Mind Blast': '정신파괴',
        'Mirage': '환영 시스템',
        'Power Plasma Alpha': '파워 플라스마 α',
        'Power Plasma Beta': '파워 플라스마 β',
        'Power Plasma Gamma': '파워 플라스마 γ',
        'Snipethoom': '저격',
        'Super Cyclone': '대형 돌개바람',
        'Ultra Flash': '초섬광',
      },
    },
  ],
};

export default triggerSet;
